import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// Element Plus 配置
export default {
  install(app) {
    // 注册 Element Plus
    app.use(ElementPlus, {
      locale: zhCn, // 设置中文语言包
      size: 'default', // 设置组件默认尺寸
      zIndex: 3000 // 设置弹窗层级
    })
    
    // 注册所有图标
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
    
    // 全局配置
    app.config.globalProperties.$ELEMENT = {
      size: 'default',
      zIndex: 3000
    }
  }
}

// 添加全局 CSS 变量来覆盖 Element Plus 的 primary 颜色
const style = document.createElement('style')
style.textContent = `
  :root {
    --el-color-primary: #2462F1 !important;
    --el-color-primary-light-3: #5c8af4 !important;
    --el-color-primary-light-5: #8ba7f7 !important;
    --el-color-primary-light-7: #b9c4f9 !important;
    --el-color-primary-light-8: #d1d9fb !important;
    --el-color-primary-light-9: #e8ecfd !important;
    --el-color-primary-dark-2: #1c4ec1 !important;
  }
`
document.head.appendChild(style)